package algorithm.recursive;

/**
 * @Name : algorithm.recursive.DiGuiCount
 * @Description : 描述
 * Created by cyd on 2021-06-15 16:56:35
 */
public class DiGuiCount {
    public static void main(String[] args) {
        System.out.println(count(100));
    }

    private static int RESULT = 0;

    public static int count(int n) {
        if (n < 0) {
            throw new RuntimeException("输入的数必须大于等于0");
        }
        if (n == 0) {
            return DiGuiCount.RESULT;
        }
        DiGuiCount.RESULT += n;

        return count(n - 1);
    }
}
